package com.java2018.springmvc.book.converter;

import org.springframework.core.convert.converter.Converter;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.lang.Nullable;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateConverter implements Converter<String,Date>{

    @Override
    public Date convert(String source) {
        System.out.println("date处理。。。");
        SimpleDateFormat dtf = new SimpleDateFormat("yyyy-MM-dd");
        try {
            return dtf.parse(source);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
}
